import 'package:flutter/material.dart';
import 'package:tiktokadult/hj_page/find/rank_module/rank_main_logic.dart';
import 'package:tiktokadult/hj_page/find/rank_module/rank_section_tab_menu.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';
import 'package:tiktokadult/tools_base/widget/keep_alive_widget.dart';

import 'rank_sub_page.dart';

//影视排行榜
class RankTypeTabView extends StatefulWidget {
  final RankType pageType;
  const RankTypeTabView(this.pageType, {super.key});

  @override
  State<RankTypeTabView> createState() => _RankTypeTabViewState();
}

class _RankTypeTabViewState extends State<RankTypeTabView> with TickerProviderStateMixin {
  List<String> tabs = ['日榜', '周榜', '月榜', '总榜'];

  late TabController tabCtr = TabController(
    initialIndex: 0,
    length: tabs.length,
    vsync: this,
  );

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        RankSectionTabMenu(
          tabTitles: (tabs.map((e) => e)).toList(),
          curIndex: 0,
          tabController: tabCtr,
        ),
        8.sizeBoxH,
        Expanded(
          child: TabBarView(
            controller: tabCtr,
            children: List.generate(
              tabs.length,
              (index) {
                return RankSubPage(
                  pageType: widget.pageType,
                  sortType: index + 1,
                ).keepAlive;
              },
            ),
          ),
        ),
      ],
    );
  }
}
